package com.yao.springcachedemo.service;

import com.yao.springcachedemo.entity.User;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import sun.rmi.runtime.Log;

/**
 * @author yao
 */
@CacheConfig(cacheNames = "user",cacheManager = "tieredCacheManager")
@Service
public class UserService {
    @CachePut(key = "#u.name")
    public User putUser(User u) {
        System.out.println("put------------------");
        return u;
    }

    @Cacheable(key = "#p0")
    public User getUser(String name) {
        System.out.println("get-----------------");
        return new User("jerry",20);
    }
}
